package org.wattdepot.cli.command;

import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the fuelType method with various inputs for correct outputs.
 * 
 * @author Alex Kan and Kelvin Green
 * @version 2.0
 */
public class TestWattDepotFuelTypes {
  WattDepotCommand commandInstance;
  String[] commandArray;
  String userInput;

  /**
   * Test WattDepotFuelTypes for correct outputs
   * 
   * Test (correct) fueltypes SIM_IPP: SIM_KALAELOA Test (correct) fueltypes SIM_HONOLULU:
   * SIM_HONOLULU_8 Test (error) fueltypes SIM_IPP 1: fueltypes {source} Test (error) fueltypes
   * SIM_IPP2: Source does not exist.
   */
  @Test
  public void testFuelTypes() {
    WattDepotCommand.connect("http://server.wattdepot.org:8182/wattdepot/");
    commandInstance = new WattDepotFuelTypesCommand();
    userInput = "fueltypes SIM_IPP";
    commandArray = userInput.split(" ");
    assertTrue("Check for fueltype", commandInstance.doCommand(commandArray).contains(
        "SIM_KALAELOA"));


    commandInstance = new WattDepotFuelTypesCommand();
    userInput = "fueltypes SIM_HONOLULU";
    commandArray = userInput.split(" ");
    assertTrue("Check for fueltype", commandInstance.doCommand(commandArray).contains(
        "SIM_HONOLULU_8"));


    commandInstance = new WattDepotFuelTypesCommand();
    userInput = "fueltypes SIM_IPP 1";
    commandArray = userInput.split(" ");
    assertTrue("Check for error", commandInstance.doCommand(commandArray).contains(
        "fueltypes {source}"));


    commandInstance = new WattDepotFuelTypesCommand();
    userInput = "fueltypes SIM_IPP2";
    commandArray = userInput.split(" ");
    assertTrue("Check for error", commandInstance.doCommand(commandArray).contains(
        "Source does not exist."));

  }
}
